package cn.aliang.cloud.payment.controller;

import cn.aliang.cloud.service.entity.ResultCode;
import cn.aliang.cloud.service.entity.ResultMessage;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Author: chendongliang
 * @Date: 2020/7/20 16:12
 */

@RestController
@RequestMapping("/payment")
@Slf4j
public class PaymentController {

    @Value("${server.port}")
    private Integer port ;

    @GetMapping("/pay/{id}")
    public ResultMessage<Void> pay(@PathVariable("id") String id ){
        System.out.println("-----------正常支付----------");
       return new ResultMessage(ResultCode.OK.getCode(),id + "-----" + port + "----成交----") ;
    }


    @GetMapping("/payForException/{id}")
    public ResultMessage<Void> payForException(@PathVariable("id") String id ){
        System.out.println("----------异常支付---------");
        //模拟接口异常
        int a = 10 / 0 ;

        return new ResultMessage(ResultCode.OK.getCode(),id + "-----" + port + "----成交----") ;
    }

}
